<!DOCTYPE html>





<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta name="generator" content="Hexo 3.9.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.3.0">
  <link rel="mask-icon" href="/images/apple-touch-icon-next.png?v=7.3.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.3.0">


<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/font-awesome@4/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.3.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":true,"scrollpercent":true},
    save_scroll: false,
    copycode: {"enable":true,"show_result":true,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: 'Copy',
      copy_success: 'Copied',
      copy_failure: 'Copy failed'
    }
  };
</script>

  <meta name="description" content="最近在配置 nginx 代理 Google analytics 的时候用到了 nginx 变量，于是在网上搜了一下，发现了这篇文章，就转了过来，不过当中有些不是很清楚，等到用到的时候再补充，这里先做备份了。原文地址在文章最下面。">
<meta name="keywords" content="Hexo,HTML,CSS,android,Linux">
<meta property="og:type" content="article">
<meta property="og:title" content="nginx内置变量 大全[转]">
<meta property="og:url" content="https://dctxf.com/nginx-variable.html">
<meta property="og:site_name" content="门口摔倒的老大爷">
<meta property="og:description" content="最近在配置 nginx 代理 Google analytics 的时候用到了 nginx 变量，于是在网上搜了一下，发现了这篇文章，就转了过来，不过当中有些不是很清楚，等到用到的时候再补充，这里先做备份了。原文地址在文章最下面。">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-06-04T06:27:51.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="nginx内置变量 大全[转]">
<meta name="twitter:description" content="最近在配置 nginx 代理 Google analytics 的时候用到了 nginx 变量，于是在网上搜了一下，发现了这篇文章，就转了过来，不过当中有些不是很清楚，等到用到的时候再补充，这里先做备份了。原文地址在文章最下面。">
  <link rel="alternate" href="/rss.xml" title="门口摔倒的老大爷" type="application/atom+xml">
  <link rel="canonical" href="https://dctxf.com/nginx-variable">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>nginx内置变量 大全[转] | 门口摔倒的老大爷</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?9ef591dac562902e43858b296afe9979";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>






  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  <div class="container sidebar-position-left">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">门口摔倒的老大爷</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-toggle">
    <button aria-label="Toggle navigation bar">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>Home</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-about">
      
    
      
    

    <a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>About</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>Tags<span class="badge">39</span></a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>Categories<span class="badge">5</span></a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>Archives<span class="badge">57</span></a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="menu-item-icon fa fa-search fa-fw"></i> <br>Search</a>
      </li>
    
  </ul>

    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="Searching..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>


    </div>
</nav>
</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content page-post-detail">
            

  <div id="posts" class="posts-expand">
    

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://dctxf.com/nginx-variable.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="dctxf">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/logo.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="门口摔倒的老大爷">
    </span>
      <header class="post-header">

        
          <h2 class="post-title" itemprop="name headline">nginx内置变量 大全[转]

            
          </h2>
        

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              
                
              

              <time title="Created: 2017-06-04 14:27:51" itemprop="dateCreated datePublished" datetime="2017-06-04T14:27:51+08:00">2017-06-04</time>
            </span>
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/code/" itemprop="url" rel="index"><span itemprop="name">code</span></a></span>

                
                
              
            </span>
          

          
            
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
        
      
      <span class="post-meta-item-text">Disqus: </span>
    
    <a title="disqus" href="/nginx-variable.html#comments" itemprop="discussionUrl">
      <span class="post-comments-count disqus-comment-count" data-disqus-identifier="nginx-variable.html" itemprop="commentCount"></span>
    </a>
  </span>
  
  
          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>最近在配置 nginx 代理 Google analytics 的时候用到了 nginx 变量，于是在网上搜了一下，发现了这篇文章，就转了过来，不过当中有些不是很清楚，等到用到的时候再补充，这里先做备份了。原文地址在文章最下面。</p>
<a id="more"></a>

<h2 id="nginx-内置变量"><a href="#nginx-内置变量" class="headerlink" title="nginx 内置变量"></a>nginx 内置变量</h2><p>内置变量存放在<code>ngx_http_core_module</code>模块中，变量的命名方式和 apache 服务器变量是一致的。总而言之，这些变量代表着客户端请求头的内容，例如<code>$http_user_agent</code>, <code>$http_cookie</code>, 等等。下面是 nginx 支持的所有内置变量：</p>
<h3 id="arg-name"><a href="#arg-name" class="headerlink" title="$arg_name"></a>$arg_name</h3><p>请求中的的参数名，即“<code>?</code>”后面的<code>arg_name=arg_value</code>形式的<code>arg_name</code></p>
<h3 id="args"><a href="#args" class="headerlink" title="$args"></a>$args</h3><p>请求中的参数值</p>
<h3 id="binary-remote-addr"><a href="#binary-remote-addr" class="headerlink" title="$binary_remote_addr"></a>$binary_remote_addr</h3><p>客户端地址的二进制形式, 固定长度为 4 个字节</p>
<h3 id="body-bytes-sent"><a href="#body-bytes-sent" class="headerlink" title="$body_bytes_sent"></a>$body_bytes_sent</h3><p>传输给客户端的字节数，响应头不计算在内；这个变量和<code>Apache</code>的<code>mod_log_config</code>模块中的“<code>%B</code>”参数保持兼容</p>
<h3 id="bytes-sent"><a href="#bytes-sent" class="headerlink" title="$bytes_sent"></a>$bytes_sent</h3><p>传输给客户端的字节数 (1.3.8, 1.2.5)</p>
<h3 id="connection"><a href="#connection" class="headerlink" title="$connection"></a>$connection</h3><p>TCP 连接的序列号 (1.3.8, 1.2.5)</p>
<h3 id="connection-requests"><a href="#connection-requests" class="headerlink" title="$connection_requests"></a>$connection_requests</h3><p>TCP 连接当前的请求数量 (1.3.8, 1.2.5)</p>
<h3 id="content-length"><a href="#content-length" class="headerlink" title="$content_length"></a>$content_length</h3><p><code>Content-Length</code> 请求头字段</p>
<h3 id="content-type"><a href="#content-type" class="headerlink" title="$content_type"></a>$content_type</h3><p><code>Content-Type</code> 请求头字段</p>
<h3 id="cookie-name"><a href="#cookie-name" class="headerlink" title="$cookie_name"></a>$cookie_name</h3><p>cookie 名称</p>
<h3 id="document-root"><a href="#document-root" class="headerlink" title="$document_root"></a>$document_root</h3><p>当前请求的文档根目录或别名</p>
<h3 id="document-uri"><a href="#document-uri" class="headerlink" title="$document_uri"></a>$document_uri</h3><p>同 $uri</p>
<h3 id="host"><a href="#host" class="headerlink" title="$host"></a>$host</h3><p>优先级如下：HTTP 请求行的主机名 &gt; ”HOST”请求头字段 &gt; 符合请求的服务器名</p>
<h3 id="hostname"><a href="#hostname" class="headerlink" title="$hostname"></a>$hostname</h3><p>主机名</p>
<h3 id="http-name"><a href="#http-name" class="headerlink" title="$http_name"></a>$http_name</h3><p>匹配任意请求头字段； 变量名中的后半部分“name”可以替换成任意请求头字段，如在配置文件中需要获取 http 请求头：“<code>Accept-Language</code>”，那么将“－”替换为下划线，大写字母替换为小写，形如：<code>$http_accept_language</code>即可。</p>
<h3 id="https"><a href="#https" class="headerlink" title="$https"></a>$https</h3><p>如果开启了 SSL 安全模式，值为“on”，否则为空字符串。</p>
<h3 id="is-args"><a href="#is-args" class="headerlink" title="$is_args"></a>$is_args</h3><p>如果请求中有参数，值为“?”，否则为空字符串。</p>
<h3 id="limit-rate"><a href="#limit-rate" class="headerlink" title="$limit_rate"></a>$limit_rate</h3><p>用于设置响应的速度限制，详见 limit_rate。</p>
<h3 id="msec"><a href="#msec" class="headerlink" title="$msec"></a>$msec</h3><p>当前的 Unix 时间戳 (1.3.9, 1.2.6)</p>
<h3 id="nginx-version"><a href="#nginx-version" class="headerlink" title="$nginx_version"></a>$nginx_version</h3><p>nginx 版本</p>
<h3 id="pid"><a href="#pid" class="headerlink" title="$pid"></a>$pid</h3><p>工作进程的 PID</p>
<h3 id="pipe"><a href="#pipe" class="headerlink" title="$pipe"></a>$pipe</h3><p>如果请求来自管道通信，值为“p”，否则为“.” (1.3.12, 1.2.7)</p>
<h3 id="proxy-protocol-addr"><a href="#proxy-protocol-addr" class="headerlink" title="$proxy_protocol_addr"></a>$proxy_protocol_addr</h3><p>获取代理访问服务器的客户端地址，如果是直接访问，该值为空字符串。(1.5.12)</p>
<h3 id="query-string"><a href="#query-string" class="headerlink" title="$query_string"></a>$query_string</h3><p>同 $args</p>
<h3 id="realpath-root"><a href="#realpath-root" class="headerlink" title="$realpath_root"></a>$realpath_root</h3><p>当前请求的文档根目录或别名的真实路径，会将所有符号连接转换为真实路径。</p>
<h3 id="remote-addr"><a href="#remote-addr" class="headerlink" title="$remote_addr"></a>$remote_addr</h3><p>客户端地址</p>
<h3 id="remote-port"><a href="#remote-port" class="headerlink" title="$remote_port"></a>$remote_port</h3><p>客户端端口</p>
<h3 id="remote-user"><a href="#remote-user" class="headerlink" title="$remote_user"></a>$remote_user</h3><p>用于 HTTP 基础认证服务的用户名</p>
<h3 id="request"><a href="#request" class="headerlink" title="$request"></a>$request</h3><p>代表客户端的请求地址</p>
<h3 id="request-body"><a href="#request-body" class="headerlink" title="$request_body"></a>$request_body</h3><p>客户端的请求主体</p>
<p>此变量可在<code>location</code>中使用，将请求主体通过<code>proxy_pass</code>, <code>fastcgi_pass</code>, <code>uwsgi_pass</code>, 和 <code>scgi_pass</code>传递给下一级的代理服务器。</p>
<h3 id="request-body-file"><a href="#request-body-file" class="headerlink" title="$request_body_file"></a>$request_body_file</h3><p>将客户端请求主体保存在临时文件中。文件处理结束后，此文件需删除。如果需要之一开启此功能，需要设置 client_body_in_file_only。如果将次文件传递给后端的代理服务器，需要禁用<code>request body</code>，即设置</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">proxy_pass_request_body off;</span><br><span class="line">fastcgi_pass_request_body off;</span><br><span class="line">uwsgi_pass_request_body off;</span><br><span class="line">//or</span><br><span class="line">scgi_pass_request_body off;</span><br></pre></td></tr></table></figure>

<h3 id="request-completion"><a href="#request-completion" class="headerlink" title="$request_completion"></a>$request_completion</h3><p>如果请求成功，值为”OK”，如果请求未完成或者请求不是一个范围请求的最后一部分，则为空。</p>
<h3 id="request-filename"><a href="#request-filename" class="headerlink" title="$request_filename"></a>$request_filename</h3><p>当前连接请求的文件路径，由 root 或 alias 指令与 URI 请求生成。</p>
<h3 id="request-length"><a href="#request-length" class="headerlink" title="$request_length"></a>$request_length</h3><p>请求的长度 (包括请求的地址, http 请求头和请求主体) (1.3.12, 1.2.7)</p>
<h3 id="request-method"><a href="#request-method" class="headerlink" title="$request_method"></a>$request_method</h3><p>HTTP 请求方法，通常为“GET”或“POST”</p>
<h3 id="request-time"><a href="#request-time" class="headerlink" title="$request_time"></a>$request_time</h3><p>处理客户端请求使用的时间 (1.3.9, 1.2.6); 从读取客户端的第一个字节开始计时。</p>
<h3 id="request-uri"><a href="#request-uri" class="headerlink" title="$request_uri"></a>$request_uri</h3><p>这个变量等于包含一些客户端请求参数的原始 URI，它无法修改，请查看$uri 更改或重写 URI，不包含主机名，例如：”/cnphp/test.php?arg=freemouse”。</p>
<h3 id="scheme"><a href="#scheme" class="headerlink" title="$scheme"></a>$scheme</h3><p>请求使用的 Web 协议, “http” 或 “https”</p>
<h3 id="sent-http-name"><a href="#sent-http-name" class="headerlink" title="$sent_http_name"></a>$sent_http_name</h3><p>可以设置任意 http 响应头字段； 变量名中的后半部分“name”可以替换成任意响应头字段，如需要设置响应头 Content-length，那么将“－”替换为下划线，大写字母替换为小写，形如：<code>$sent_http_content_length 4096</code>即可。</p>
<h3 id="server-addr"><a href="#server-addr" class="headerlink" title="$server_addr"></a>$server_addr</h3><p>服务器端地址，需要注意的是：为了避免访问 linux 系统内核，应将 ip 地址提前设置在配置文件中。</p>
<h3 id="server-name"><a href="#server-name" class="headerlink" title="$server_name"></a>$server_name</h3><p>服务器名</p>
<h3 id="server-port"><a href="#server-port" class="headerlink" title="$server_port"></a>$server_port</h3><p>服务器端口</p>
<h3 id="server-protocol"><a href="#server-protocol" class="headerlink" title="$server_protocol"></a>$server_protocol</h3><p>服务器的 HTTP 版本, 通常为 “HTTP/1.0” 或 “HTTP/1.1”</p>
<h3 id="status"><a href="#status" class="headerlink" title="$status"></a>$status</h3><p>HTTP 响应代码 (1.3.2, 1.2.2)</p>
<h3 id="tcpinfo-rtt-tcpinfo-rttvar-tcpinfo-snd-cwnd-tcpinfo-rcv-space"><a href="#tcpinfo-rtt-tcpinfo-rttvar-tcpinfo-snd-cwnd-tcpinfo-rcv-space" class="headerlink" title="$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space"></a>$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space</h3><p>客户端 TCP 连接的具体信息</p>
<h3 id="time-iso8601"><a href="#time-iso8601" class="headerlink" title="$time_iso8601"></a>$time_iso8601</h3><p>服务器时间的 ISO 8610 格式 (1.3.12, 1.2.7)</p>
<h3 id="time-local"><a href="#time-local" class="headerlink" title="$time_local"></a>$time_local</h3><p>服务器时间（LOG Format 格式） (1.3.12, 1.2.7)</p>
<h3 id="uri"><a href="#uri" class="headerlink" title="$uri"></a>$uri</h3><p>请求中的当前 URI(不带请求参数，参数位于<code>$args</code>)，可以不同于浏览器传递的<code>$request_uri</code>的值，它可以通过内部重定向，或者使用 index 指令进行修改，$uri 不包含主机名，如”<code>/foo/bar.html</code>”。</p>
<blockquote>
<p>原文 <a href="http://www.cnphp.info/nginx-embedded-variables-lasted-version.html?utm_source=tuicool&amp;utm_medium=referral" target="_blank" rel="noopener">http://www.cnphp.info/nginx-embedded-variables-lasted-version.html?utm_source=tuicool&amp;utm_medium=referral</a></p>
</blockquote>

    </div>

    
    
    
        
      

      <footer class="post-footer">

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/negative-energy-happy.html" rel="next" title="负能量鸡汤段子 给自己一点启发">
                  <i class="fa fa-chevron-left"></i> 负能量鸡汤段子 给自己一点启发
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/some-ideas.html" rel="prev" title="几本书的一些感想">
                  几本书的一些感想 <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    
  <div class="comments" id="comments">
    <div id="disqus_thread">
      <noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
    </div>
  </div>
  
  

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="/images/logo.png"
      alt="dctxf">
  <p class="site-author-name" itemprop="name">dctxf</p>
  <div class="site-description motion-element" itemprop="description"></div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">57</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">5</span>
        <span class="site-state-item-name">categories</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">39</span>
        <span class="site-state-item-name">tags</span>
        </a>
      </div>
    
  </nav>
  <div class="feed-link motion-element">
    <a href="/rss.xml" rel="alternate">
      <i class="fa fa-rss"></i>RSS
    </a>
  </div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/dctxf" title="GitHub &rarr; https://github.com/dctxf" rel="noopener" target="_blank"><i class="fa fa-fw fa-globe"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="/" title="Weibo &rarr; "><i class="fa fa-fw fa-globe"></i>Weibo</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="/dctxf" title="Twitter &rarr; dctxf"><i class="fa fa-fw fa-globe"></i>Twitter</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="/dctxf" title="FB Page &rarr; dctxf"><i class="fa fa-fw fa-globe"></i>FB Page</a>
      </span>
    
  </div>


  <div class="links-of-blogroll motion-element links-of-blogroll-block">
    <div class="links-of-blogroll-title">
      <i class="fa  fa-fw fa-link"></i>
      Links
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="http://iwuly.com/" title="http://iwuly.com/" rel="noopener" target="_blank">iwuly</a>
        </li>
      
        <li class="links-of-blogroll-item">
          <a href="http://mybulesea.github.io/" title="http://mybulesea.github.io/" rel="noopener" target="_blank">深蓝</a>
        </li>
      
        <li class="links-of-blogroll-item">
          <a href="http://chayangge.com/" title="http://chayangge.com/" rel="noopener" target="_blank">插秧哥</a>
        </li>
      
    </ul>
  </div>

        </div>
      </div>
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#nginx-内置变量"><span class="nav-number">1.</span> <span class="nav-text">nginx 内置变量</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#arg-name"><span class="nav-number">1.1.</span> <span class="nav-text">$arg_name</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#args"><span class="nav-number">1.2.</span> <span class="nav-text">$args</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#binary-remote-addr"><span class="nav-number">1.3.</span> <span class="nav-text">$binary_remote_addr</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#body-bytes-sent"><span class="nav-number">1.4.</span> <span class="nav-text">$body_bytes_sent</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#bytes-sent"><span class="nav-number">1.5.</span> <span class="nav-text">$bytes_sent</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#connection"><span class="nav-number">1.6.</span> <span class="nav-text">$connection</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#connection-requests"><span class="nav-number">1.7.</span> <span class="nav-text">$connection_requests</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#content-length"><span class="nav-number">1.8.</span> <span class="nav-text">$content_length</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#content-type"><span class="nav-number">1.9.</span> <span class="nav-text">$content_type</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#cookie-name"><span class="nav-number">1.10.</span> <span class="nav-text">$cookie_name</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#document-root"><span class="nav-number">1.11.</span> <span class="nav-text">$document_root</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#document-uri"><span class="nav-number">1.12.</span> <span class="nav-text">$document_uri</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#host"><span class="nav-number">1.13.</span> <span class="nav-text">$host</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#hostname"><span class="nav-number">1.14.</span> <span class="nav-text">$hostname</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#http-name"><span class="nav-number">1.15.</span> <span class="nav-text">$http_name</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#https"><span class="nav-number">1.16.</span> <span class="nav-text">$https</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#is-args"><span class="nav-number">1.17.</span> <span class="nav-text">$is_args</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#limit-rate"><span class="nav-number">1.18.</span> <span class="nav-text">$limit_rate</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#msec"><span class="nav-number">1.19.</span> <span class="nav-text">$msec</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#nginx-version"><span class="nav-number">1.20.</span> <span class="nav-text">$nginx_version</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#pid"><span class="nav-number">1.21.</span> <span class="nav-text">$pid</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#pipe"><span class="nav-number">1.22.</span> <span class="nav-text">$pipe</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#proxy-protocol-addr"><span class="nav-number">1.23.</span> <span class="nav-text">$proxy_protocol_addr</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#query-string"><span class="nav-number">1.24.</span> <span class="nav-text">$query_string</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#realpath-root"><span class="nav-number">1.25.</span> <span class="nav-text">$realpath_root</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#remote-addr"><span class="nav-number">1.26.</span> <span class="nav-text">$remote_addr</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#remote-port"><span class="nav-number">1.27.</span> <span class="nav-text">$remote_port</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#remote-user"><span class="nav-number">1.28.</span> <span class="nav-text">$remote_user</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request"><span class="nav-number">1.29.</span> <span class="nav-text">$request</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request-body"><span class="nav-number">1.30.</span> <span class="nav-text">$request_body</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request-body-file"><span class="nav-number">1.31.</span> <span class="nav-text">$request_body_file</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request-completion"><span class="nav-number">1.32.</span> <span class="nav-text">$request_completion</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request-filename"><span class="nav-number">1.33.</span> <span class="nav-text">$request_filename</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request-length"><span class="nav-number">1.34.</span> <span class="nav-text">$request_length</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request-method"><span class="nav-number">1.35.</span> <span class="nav-text">$request_method</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request-time"><span class="nav-number">1.36.</span> <span class="nav-text">$request_time</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#request-uri"><span class="nav-number">1.37.</span> <span class="nav-text">$request_uri</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#scheme"><span class="nav-number">1.38.</span> <span class="nav-text">$scheme</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#sent-http-name"><span class="nav-number">1.39.</span> <span class="nav-text">$sent_http_name</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#server-addr"><span class="nav-number">1.40.</span> <span class="nav-text">$server_addr</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#server-name"><span class="nav-number">1.41.</span> <span class="nav-text">$server_name</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#server-port"><span class="nav-number">1.42.</span> <span class="nav-text">$server_port</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#server-protocol"><span class="nav-number">1.43.</span> <span class="nav-text">$server_protocol</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#status"><span class="nav-number">1.44.</span> <span class="nav-text">$status</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#tcpinfo-rtt-tcpinfo-rttvar-tcpinfo-snd-cwnd-tcpinfo-rcv-space"><span class="nav-number">1.45.</span> <span class="nav-text">$tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, $tcpinfo_rcv_space</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#time-iso8601"><span class="nav-number">1.46.</span> <span class="nav-text">$time_iso8601</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#time-local"><span class="nav-number">1.47.</span> <span class="nav-text">$time_local</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#uri"><span class="nav-number">1.48.</span> <span class="nav-text">$uri</span></a></li></ol></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2015 – <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">dctxf</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> v3.9.0</div>

        








        
      </div>
    </footer>

    

  </div>

  
  <script src="//cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

<script src="/js/utils.js?v=7.3.0"></script>
  <script src="/js/motion.js?v=7.3.0"></script>


  <script src="/js/affix.js?v=7.3.0"></script>
  <script src="/js/schemes/pisces.js?v=7.3.0"></script>



<script src="/js/next-boot.js?v=7.3.0"></script>




  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>















  <script src="/js/local-search.js?v=7.3.0"></script>














  

  

  


  
  <script src="/js/scrollspy.js?v=7.3.0"></script>
<script src="/js/post-details.js?v=7.3.0"></script>


    
<script>
  function loadCount() {
    var d = document, s = d.createElement('script');
    s.src = 'https://dctxf.disqus.com/count.js';
    s.id = 'dsq-count-scr';
    (d.head || d.body).appendChild(s);
  }
  // defer loading until the whole page loading is completed
  window.addEventListener('load', loadCount, false);
</script>
<script>
  var disqus_config = function() {
    this.page.url = "https://dctxf.com/nginx-variable.html";
    this.page.identifier = "nginx-variable.html";
    this.page.title = 'nginx内置变量 大全[转]';};
  function loadComments() {
    if (window.DISQUS) {
      DISQUS.reset({
        reload: true,
        config: disqus_config
      });
    } else {
      var d = document, s = d.createElement('script');
      s.src = 'https://dctxf.disqus.com/embed.js';
      s.setAttribute('data-timestamp', '' + +new Date());
      (d.head || d.body).appendChild(s);
    }
  }
    $(function() {
      var offsetTop = $('#comments').offset().top - $(window).height();
      if (offsetTop <= 0) {
        // load directly when there's no a scrollbar
        window.addEventListener('load', loadComments, false);
      } else {
        $(window).on('scroll.disqus_scroll', function() {
          // offsetTop may changes because of manually resizing browser window or lazy loading images.
          var offsetTop = $('#comments').offset().top - $(window).height();
          var scrollTop = $(window).scrollTop();

          // pre-load comments a bit? (margin or anything else)
          if (offsetTop - scrollTop < 60) {
            $(window).off('.disqus_scroll');
            loadComments();
          }
        });
      }
    });
  
</script>

</body>
</html>
